﻿using CozeDomain.Entities;
using CozeDomain.IRepositories;
using CozeDomain.IServices; 
using D.Tool.CodeBuild.Models;
using D.UtilCore.Dtos;
using D.UtilFreesqlOrm;

namespace CozeDomain.Services
{
    /// <summary>
    /// 
    /// </summary>
    public class SysCodeBuilderService : BaseService<SysCodeBuilderEntity>, ISysCodeBuilderService
    {
        private readonly ISysCodeBuilderRepository _repository;
        /// <summary>
        /// 构造注入
        /// </summary>
        public SysCodeBuilderService(ISysCodeBuilderRepository repository)
        {
            // 用于base方法
            base._baseDal = repository;
            this._repository = repository;
        }

        /// <summary>
        /// 获取库列表
        /// </summary>
        /// <returns></returns>
        public ApiResult<IEnumerable<string>> GetDbList()
        {
            return new ApiResult<IEnumerable<string>>() { Code = StatusCodeEnum.OK, Data = _repository.GetDbList() };
        }

        /// <summary>
        /// 获取表列表
        /// </summary>
        /// <param name="dbName"></param>
        /// <returns></returns>
        public ApiResult<IEnumerable<TablesInput>> GetTableList(string dbName)
        {
            return new ApiResult<IEnumerable<TablesInput>>() { Code = StatusCodeEnum.OK, Data = _repository.GetTableList(dbName) };
        }
    }
}
